import { ComponentInternalInstance, getCurrentInstance } from "vue";

export default function useCurrentInstance() {
  if (!getCurrentInstance()) {
    throw new Error(
      "useCurrentInstance() can only be used inside setup() or functional components!"
    );
  }
  const { appContext } = getCurrentInstance() as ComponentInternalInstance;
  const proxy = appContext.config.globalProperties;
  return {
    proxy,
  };
}

// export default function useCurrentInstance() {
//   const { appContext } = getCurrentInstance() as ComponentInternalInstance;
//   const globalProperties = appContext.config.globalProperties;
//   return {
//     globalProperties,
//   };
// }
